import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;


public class ViewHolder {

	
	private static int horizontalGap; //gap between layout components
	private static int verticalGap; //gap between layout components
	/**
	 * layout of the window
	 */
	private static BorderLayout layout = new BorderLayout(horizontalGap,verticalGap);
	/**
	 * height of the window
	 */
	public static int windowHeight = 600;
	/**
	 * width of the window
	 */
	public static int windowWidth = 800;
	/**
	 * X position of the window
	 */
	public static int windowPositionX = windowWidth/2;
	/**
	 * Y position of the window
	 */
	public static int windowPositionY = windowHeight/2;
	
	public static void main(String[] a) {
	    JFrame window = new JFrame("Lego 3D");
	    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    window.setBounds(windowPositionX, windowPositionY, windowWidth, windowHeight);
	    
	    
	 
	    //dummy components for outer areas
	    JLabel label_west = new JLabel("History",SwingConstants.CENTER);
	    JLabel label_east = new JLabel("<html><body>Saved<br>Components</body></html>",SwingConstants.CENTER);
	    JLabel label_north = new JLabel("Select View",SwingConstants.CENTER);
	    //size for the outer regions
	    label_west.setPreferredSize(new Dimension((int)(windowWidth*0.15),(int) (windowHeight*0.7)));
	    label_east.setPreferredSize(new Dimension((int)(windowWidth*0.15),(int) (windowHeight*0.7)));
	    label_north.setPreferredSize(new Dimension(windowWidth,(int) (windowHeight*0.2)));
	    //colored to see regions
	    label_west.setOpaque(true);
	    label_east.setOpaque(true);
	    label_north.setOpaque(true);
	    label_west.setBackground(Color.DARK_GRAY);
	    label_east.setBackground(Color.LIGHT_GRAY);
	    label_north.setBackground(Color.MAGENTA);
	    //font for the labels
	    label_west.setFont(new Font("Courier New",1,15));
	    label_east.setFont(new Font("Courier New",1,15));
	    label_north.setFont(new Font("Courier New",1,20));
	    
	   
	    //add components to layout
	    layout.addLayoutComponent(label_west, BorderLayout.WEST);
	    layout.addLayoutComponent(label_east, BorderLayout.EAST);
	    layout.addLayoutComponent(label_north, BorderLayout.NORTH);
	    layout.addLayoutComponent(new MyCanvas(), BorderLayout.CENTER);
	  
	    //add components
	    window.setLayout(layout);
	    window.getContentPane().add(label_east);
	    window.getContentPane().add(label_north);
	    window.getContentPane().add(label_west);
	    window.getContentPane().add(new MyCanvas());
	    window.setResizable(false);
	    window.setVisible(true);
	    
	  }
}

class MyCanvas extends JComponent {
		
	ServerInfo server = new ServerInfo();
	
  public void paint(Graphics g) { 
    g.setColor(Color.decode(server.getBrickColor()));
    g.fillRect(server.getX_pos(), server.getY_pos(), server.getWidth(), server.getHeight());
  }
}
